<template>
    <view>
        <button type="primary" @click="setStorage"></button>
        <button type="primary" @click="getStorage"></button>
        <button type="primary" @click="removeId"></button>
        <button type="primary" @click="chooseImg"></button>
        <image v-for="item in imgArr" :src="item"></image>
        <!-- #ifdef H5-->
        <view></view>
        <!--#endif-->
        <!--#ifdef MP-WEIXIN-->
        <view></view>
        <!--#endif-->
        <!--ifdef APP-PLUS-->
        <view></view>
        <!--#endif-->
        <view>
            <button @click="pullDown"></button>
            <view>1</view>
            <view class="box-item" v-for="item in list">
                {{item}}
            </view>
        </view>
    </view>
</template>

<script>
export default{
    data(){
        return{
            list:['1','2','3','4','5'],
            imgArr:[]
        }
    },
    onLoad(){
        // #ifdef H5
        // #endif
        // #ifdef MP-WEIXIN
        // #endif
    },
    onShow(){},
    onReady(){},
    onHide(){},
    onPullDownRefresh(){
        setTimeout(()=>{
            this.list = ['11','22','33','44','55']
            uni.stopPullDownRefresh()
        },2000)       
    },
    onReachBottom(){
        this.list = [...this.list, ...['11','22','33','44','55']]
    }
    ,
    methods:{
        setStorage(){
            uni.setStorageSync('ip',100)   
        },
        getStorage(){
            const res = uni.getStorageSync('id')
            console.log(res)
        },
        removeId(){
            uni.removeStorageSync('id')
        },
        pullDown(){
                uni.startPullDownRefresh()      
        },
        chooseImg(){
            uni.chooseImage({
                count:5,
                success:res()=>{
                    this.imgArr = res.tempFilePaths 
                }
            })
        },
        previewImg(crt){
            uni.previewImage({
                crt,
                urls:this.imgArr,
                loop:true,
                indicator:'default'
            )
        }
    }
}

</script>

<style>
.box-item{
    height:100px;
    line-height:100px
}
/* #ifdef H5*/
view{
    color:hotpink
}    
/*#endif*/

/*#ifdef MP-WEIXIN*/
view{
    color:'blue'
}
/*#endif*/
</style>